package com.liucxu.zimuzu.Base;

import com.liucxu.zimuzu.Model.Bean.BaseBean;

import rx.Subscriber;

/**
 * Created by liucxu on 2016/12/9.
 */

public abstract class ResponseSubscriber<T extends BaseBean> extends Subscriber<T> {
    @Override
    public void onNext(T baseBean) {
        if (baseBean.getStatus() == 1) {
            onSuccess(baseBean);
        } else {
            Throwable e=new Throwable(baseBean.getInfo());
            onFailure(e);
        }
    }

    @Override
    public void onError(Throwable e) {
        e.printStackTrace();
        onFailure(e);
    }

    @Override
    public void onCompleted() {

    }

    public abstract void onSuccess(T bean);

    public abstract void onFailure(Throwable error);
}
